<?php
if (isset($_POST["whichForm"]))
	{
		switch ($_POST["whichForm"])
		{
			case "domain":
			if (isset($_POST['nomDo']) && isset($_POST['descDo']) && isset($_SESSION['theso']))
			{
				$ajoutDo = pg_query($db, "SELECT * FROM ADD_DOMAIN ('".$_POST['nomDo']."', '".$_POST['descDo']."', '".$_SESSION['theso']."' );");
			}
			break;
			
			case "concept": 
			if (isset($_POST['ended']))
			{
			if ($_POST['ended'] == "yes")
			{
				if (isset($_POST['listTS']))
				{
					$TS = "{";
					foreach( $_POST['listTS'] as $value) 
					{
						$TS = $TS . $value . ", " ;// traitements : $value contient les valeurs successives 
					}
					$TS[strlen($TS)-2] ="}";
				}
				else
				{
					$TS = "{}";
				}

				if (isset($_POST['listTG']))
				{
					$TG = "{";
					foreach($_POST['listTG'] as $value) 
					{
						$TG = $TG . $value . ", " ;// traitements : $value contient les valeurs successives 
					}
					$TG[strlen($TG)-2] ="}";
				}
				else
				{
					$TG = "{}";
				}

				if (isset($_POST['listT']))
				{
					$T = "{";
					foreach( $_POST['listT'] as $value) 
					{
						$T = $T . $value . ", " ;// traitements : $value contient les valeurs successives 
					}
					$T[strlen($T)-2] ="}";
				}
				else
				{
					$T = "{}";
				}



				if (isset($_POST['termeV']) && isset($_POST['Domain']))
				{
					$ajoutDo = pg_query($db, "SELECT * FROM ADD_CONCEPT ('".$_POST['termeV']."','".$_POST['Domain']."','".$_POST['termeV']."','". $T ."','". $TS . "','". $TG ."');");
				}
			}}
			break;

			case "assoc":
			if (isset($_POST['assName']))
			{
				if (isset($_POST['Rf']) && $_POST['Rf'] == "on")
				{$bool = 'TRUE';}
				else
				{$bool = 'FALSE';}
					
				$ajoutConcept = pg_query($db, "SELECT * FROM ADD_ASSOCIATION ('".$_POST['assName']."', '".$_POST['CP1']."', '".$_POST['CP2']."',".$bool.")");
			}
			break;
		}
	}
?>
